﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLCMS.Data.Accessor;
using ZLCMS.Business;
using System.Text;
using NHibernate.Criterion;
using NHibernate;
using System.Collections;
using ZLCMS.Data.Model;
using ZLCMS.Business.DwzFrame;
using ZLCMS.Business.Config;
using Newtonsoft.Json;

namespace ZLCMS.Web.Example.MessageBoard
{
    public partial class MessageBoard : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            IMessageAccessor messageAcc = new AccessorFactory().GetMessageAccessor();
            ICriteria criteria = messageAcc.CreateCriteria();
            criteria.Add(Expression.Eq("Status","1")).AddOrder(Order.Desc("Addtime"));

            rp_message.DataSource = criteria.List();
            rp_message.DataBind();
        }

        public string GetMessageReply(int messageId)
        {
            StringBuilder tmpBuilder = new StringBuilder();
            IMessageReplyAccessor _messageReplyAcc = new AccessorFactory().GetMessageReplyAccessor();
            IList<MessageReply> messageReplyList = _messageReplyAcc.GetById(messageId);

            if (messageReplyList.Count == 0)
            {
                return "[尚未回复]";
            }
            else
            {
                foreach (MessageReply tmp in messageReplyList)
                {
                    //tmpBuilder.Append("<tr><td>" + tmp.Content + "</td></tr>");
                    tmpBuilder.Append("<span>" + tmp.Content + "</span></br>");
                }
            }
            return tmpBuilder.ToString();
        }
    }
}
